package com.haha.helloworld;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.haha.helloworld.widget.CustomDialog;

public class CustomDialogActivity extends AppCompatActivity {
    private Button btn_custom_dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_dialog);
        btn_custom_dialog=(Button)findViewById(R.id.btn_custom_dialog);
        btn_custom_dialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //可以传入一个layout，但是没必要
//                CustomDialog customDialog = new CustomDialog(CustomDialogActivity.this,R.style.CustomDialog);
                CustomDialog customDialog = new CustomDialog(CustomDialogActivity.this);
                customDialog.setTitle("提示");
                customDialog.setMessage("确认删除此项？");
                customDialog.setCancel("取消", new CustomDialog.IOnCancelListener() {
                    @Override
                    public void onCancel(CustomDialog dialog) {
                        Toast.makeText(CustomDialogActivity.this, "点击取消了" , Toast.LENGTH_SHORT).show();

                    }
                }).setComfirm("确认", new CustomDialog.IOnComfirmListener() {
                    @Override
                    public void onComfirm(CustomDialog dialog) {
                        Toast.makeText(CustomDialogActivity.this, "点击确定了" , Toast.LENGTH_SHORT).show();
                    }
                }).show();
            }
        });
    }
}